package top.tungsword.webconsole.util;

import org.apache.commons.lang3.StringUtils;

/**
 * @author chenji.yu
 * @date 2020/4/28 10:43
 * @description
 * 参数验证工具类
 */
public class ParamCheckUtil {
    public static void notNullCheck(String param, String message, StringBuffer msb){
        if(StringUtils.isEmpty(param)){
            if(msb.length() == 0){
                msb.append(message);
            }
        }
    }

    public static void lengthCheck(String param, int maxLength, String message, StringBuffer msb){
        lengthCheck(param, 0, maxLength, message, msb);
    }

    public static void lengthCheck(String param, int minLength, int maxLength, String message, StringBuffer msb){
        if(StringUtils.isEmpty(param) || param.trim().length() < minLength || param.trim().length() > maxLength){
            if(msb.length() == 0){
                msb.append(message);
            }
        }
    }
}
